package com.example.springboot.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.whitelist.annotation.DoWhiteList;

@RestController
public class WhiteListController {
	
	private Logger logger = LoggerFactory.getLogger(WhiteListController.class);
	
	/**
	 * 通过：http://localhost:8081/api/queryUserInfo?userId=aaa
	 * 拦截：http://localhost:8081/api/queryUserInfo?userId=123
	 */
	@DoWhiteList(key = "userId", returnJson = "{\"code\":\"1111\",\"info\":\"非白名单可访问用户拦截！\"}")
	@GetMapping(path = "/api/queryUserInfo")
	public UserInfo queryUserInfo(@RequestParam String userId) {
		logger.info("查询用户信息，userId：{}", userId);
		return new UserInfo("虫虫:" + userId, 19, "天津市东丽区万科赏溪苑14-0000");
	}
	
	
}

